﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Model
{
    [Table("Person")]
    public class Person
    {
        /// <summary>
        /// 编号
        /// </summary>
        [Key()]
        public long ID { get; set; }

        public long NationID { get; set; }
        public long PoliticalStatusID { get; set; }
        public long ProfessionID { get; set; }
        public long RelationID { get; set; }
        public Guid AreaID { get; set; }

        /// <summary>
        /// 户主编号
        /// </summary>
        public long MasterID { get; set; }
        /// <summary>
        /// 姓名
        /// </summary>
        [MinLength(1, ErrorMessage = "姓名必须输入！"), MaxLength(100, ErrorMessage = "姓名不能超过100个字符！")]
        public string Name { get; set; }

        /// <summary>
        /// 身份证号码
        /// </summary>
        [MaxLength(18, ErrorMessage = "身份证号码不能超过18个字符！")]
        public string PIN { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        public SexEnum Sex { get; set; }

        [NotMapped()]
        public string SexName { get { return Sex == SexEnum.Male ? "男" : "女"; } }

        /// <summary>
        /// 是否健在
        /// </summary>
        public bool IsAlive { get; set; }

        /// <summary>
        /// 是否户主
        /// </summary>
        public bool IsHead { get; set; }

        /// <summary>
        /// 出生日期
        /// </summary>
        public DateTime Birthday { get; set; }

        /// <summary>
        /// 照片资源路径
        /// </summary>
        [MaxLength(50, ErrorMessage = "照片资源路径不能超过500个字符！")]
        public string PhotoURI { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public byte[] HeadSculptureImage { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        [MaxLength(100, ErrorMessage = "地址不能超过500个字符！")]
        public string Address { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [MaxLength(50, ErrorMessage = "备注不能超过500个字符！")]
        public string Remark { get; set; }

        /// <summary>
        /// 民族
        /// </summary>
        [ForeignKey("NationID")]
        public Nation Nation { get; set; }

        /// <summary>
        /// 职业
        /// </summary>
        [ForeignKey("ProfessionID")]
        public Profession Profession { get; set; }

        /// <summary>
        /// 政治面貌
        /// </summary>
        [ForeignKey("PoliticalStatusID")]
        public PoliticalStatus PoliticalStatus { get; set; }

        /// <summary>
        /// 与户主的关系
        /// </summary>
        [ForeignKey("RelationID")]
        public Relation Relation { get; set; }

        /// <summary>
        /// 区域
        /// </summary>
        [ForeignKey("AreaID")]
        public Area Area { get; set; }

        /// <summary>
        /// 是否军属
        /// </summary>
        public bool IsArmyFamily { get; set; }

        /// <summary>
        /// 是否五保户
        /// </summary>
        public bool IsWBH { get; set; }
    }
}
